﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using JobSiteStarterKit.DAL;

public partial class UserControls_CategoryJobSearch : System.Web.UI.UserControl
{
    private int categoryCode;
    public int CategoryCode
    {
        get
        {
            return categoryCode;
        }
        set
        {
            categoryCode = value;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindMe();
        }
    }
  
    private void BindMe()
    {
        using (DBAccess obj = new DBAccess())
        {
            obj.CommandText = "Jobsdb_Category_Select";
            DataSet ds = new DataSet();
            ds = obj.ExecuteDataSet();
            
                dgrd.DataSource = ds;
                dgrd.DataBind();
           
        }
        

    }
    
  
    protected void dgrd_ItemCommand(object source, DataGridCommandEventArgs e)
    {
        if (e.CommandName == "code")
        {
            CategoryCode = Convert.ToInt32(e.CommandArgument);
            Response.Redirect("jobsearch.aspx?cat=" + Convert.ToString(CategoryCode));
        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("jobsearch.aspx");
    }
    protected void dgrd_PageIndexChanged1(object source, DataGridPageChangedEventArgs e)
    {
        dgrd.CurrentPageIndex = e.NewPageIndex;
        BindMe();
    }
}
